using System;
using System.Collections;

namespace Evaluant.Uss.Commands
{
	[Serializable]
	public abstract class ReferenceCommand : Command
	{

		protected string _Role;
		protected string _ParentType;
		protected string _ChildType;
		protected string _ChildId;

		public string ParentType
		{
			get { return _ParentType; }
			set { _ParentType = value; }
		}

		public string ChildId
		{
			get { return _ChildId; }
			set { _ChildId = value; }
		}

		public string ChildType
		{
			get { return _ChildType; }
			set { _ChildType = value; }
		}

		public string Role
		{
			get { return _Role; }
			set { _Role = value; }
		}

		public ReferenceCommand(string role, string parentId, string parentType, string childId, string childType) : base(parentId)
		{
			_ParentId = parentId;
			_ParentType = parentType;
			_ChildId = childId;
			_ChildType = childType;
			_Role = role;
		}

		public override void UpdateIds(Hashtable newIds)
		{
			base.UpdateIds(newIds);

			if(newIds.Contains(ChildId))
				ChildId = (string)newIds[ChildId];
		}

	}
}
